<template>
  <div class="basic-layout">
    <div class="nav-side">
      <!-- 系统LOGO -->
      <div class="logo">
        <img src="../assets/logo.png" alt="" />
        <span>Manager</span>
      </div>

      <!-- 导航菜单 : 强调一下,这个菜单后期是需要动态渲染的,而不是写死的,暂时我们先写死,后期要重构导航菜单 -->
      <el-menu
        :default-active="$route.path"
        class="el-menu-vertical-demo"
        background-color="#001529"
        router
        text-color="#fff"
        active-text-color="#ffd04b"
      >
        <tree-menu :menuList="menuList"></tree-menu>
      </el-menu>
    </div>
    <div class="content-right">
      <div class="nav-top">
        <!-- 左侧面包屑 -->
        <div class="nav-left">
          <!-- 菜单图标 -->
          <div class="menu-fold">
            <i class="el-icon-s-fold"></i>
          </div>
          <!-- 面包屑 -->
          <div class="bread">
            <BreadCrumb></BreadCrumb>
          </div>
        </div>
        <!-- 右侧下拉菜单 -->
        <div class="user-info">
          <!-- 消息通知图标 -->
          <el-badge class="notice">
            <i class="el-icon-bell"></i>
          </el-badge>
          <!-- 下拉菜单 -->
          <el-dropdown>
            <span class="el-dropdown-link user-link">
              {{$store.state.userInfo.userName || ""}}
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item >邮箱: {{$store.state.userInfo.userEmail}}</el-dropdown-item>
              <el-dropdown-item >退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
      </div>
      <div class="wrapper">
        <div class="main-page">
          <router-view></router-view>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import BreadCrumb from "./BreadCrumb.vue";
import TreeMenu from "./TreeMenu.vue"
export default {
  name: "",
  data() {
    return {
      menuList : []
    };
  },
  components: {
    BreadCrumb,
    TreeMenu
  },
  created(){
    this.getMenuList()
  },
  methods : {
    async getMenuList(){
      let res = await this.userApi.getPermissionList();
      console.log(res)
      this.$store.commit("saveMenuList",res.menuList);
      this.$store.commit("saveActionList",res.actionList);
      this.menuList = res.menuList;
    }
  }
};
</script>

<style scoped lang="scss">
.basic-layout {
  position: relative;

  .nav-side {
    position: fixed;
    width: 200px;
    height: 100vh;
    background-color: #001529;
    color: #fff;
    overflow-y: auto;

    .logo {
      display: flex;
      align-items: center;
      font-size: 18px;
      height: 50px;
      img {
        margin: 0 16px;
        width: 32px;
        height: 32px;
      }
    }

    .el-menu {
      border-right: 0;
    }
  }

  .content-right {
    margin-left: 200px;

    .nav-top {
      height: 50px;
      background-color: #fff;
      padding: 0 20px;
      border-bottom: 1px solid #ddd;
      display: flex;
      align-items: center;
      justify-content: space-between;
      position: fixed;
      right: 0;
      z-index:9999;
      left: 200px;

      .nav-left {
        display: flex;
        align-items: center;
        .menu-fold {
          font-size: 18px;
          margin-right: 15px;
        }
      }
      .user-info{
        .notice{
          margin-right : 15px;
          line-height: 30px;
          cursor: pointer;
        }
        .user-link{
          cursor: pointer;
          color : #409eff;
        }
        .el-dropdown-menu__item:hover {
          color: #333 !important;
        }
      }
    }

    .wrapper {
      background: #eef0f3;
      height: 100%;
      // height : calc(100vh - 50px);
      padding: 20px;
      padding-top: 71px;
      .main-page {
        min-height: calc(100vh - 50px);
        height: 100%;
        // background: #fff;
      }
    }
  }
}
</style>
